/*
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef DEVMON_OBJECT_GROUP_INTERFACE_H
#define DEVMON_OBJECT_GROUP_INTERFACE_H

#include "csr_parser.h"
#include <mc/engine.h>

template <typename T>
using property = mc::engine::property<T>;

namespace devmon {

using object_tuple_t       = std::tuple<std::string, std::string, std::string, std::string>;
using object_group_tuple_t = std::tuple<std::string, std::vector<object_tuple_t>, uint32_t>;

class object_group_interface : public mc::engine::interface<object_group_interface> {
public:
    MC_INTERFACE("bmc.dev.ObjectGroup")
    object_group_interface() = default;
    // 禁用复制构造和赋值
    object_group_interface(const object_group_interface&)            = delete;
    object_group_interface& operator=(const object_group_interface&) = delete;

    property<std::string>              Position;        ///< 位置
    property<std::vector<std::string>> Owners;          ///< 所有者
    property<uint64_t>                 OnlineTimestamp; ///< 上线时间，来源为tick数， 单位为ms
    property<uint8_t>                  Slot;            ///< 槽位

    object_group_tuple_t GetObjects(std::map<std::string, std::string> ctx, std::string_view owner);
    std::string          GetTopology(std::map<std::string, std::string> ctx);
    void                 init(std::string position, uint64_t online_timestamp, uint8_t slot);
};

} // namespace devmon

#endif // DEVMON_OBJECT_GROUP_INTERFACE_H